package top.sdwu_top.kbase.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import top.sdwu_top.kbase.common.annocation.CurrentUser;
import top.sdwu_top.kbase.common.model.Wrapper;
import top.sdwu_top.kbase.entity.KbaseAuthUser;
import top.sdwu_top.kbase.entity.KbaseFileVersionApply;
import top.sdwu_top.kbase.service.IKbaseFileVersionApplyService;
import top.sdwu_top.kbase.vo.KbaseFileVersionApplyVo;

/**
 * <p>
 * 文档贡献申请 前端控制器
 * </p>
 *
 * @author zhipeng.duan@nvr-china.com
 * @since 2020-03-14
 */
@RestController
@RequestMapping("api/file-apply")
public class KbaseFileVersionApplyController {

    @Autowired
    IKbaseFileVersionApplyService applyService;

    @PutMapping("pass/{id}")
    public Wrapper<String> pass(@CurrentUser KbaseAuthUser user, @PathVariable("id") String id) {
        if (applyService.pass(user, id)) {
            return Wrapper.ok("通过成功");
        }
        return Wrapper.ok("通过失败");
    }

    @PutMapping("abort/{id}")
    public Wrapper<String> abort(@CurrentUser KbaseAuthUser user, @PathVariable("id") String id) {
        if (applyService.abort(user, id)) {
            return Wrapper.ok("通过成功");
        }
        return Wrapper.ok("通过失败");
    }

    @PostMapping("page")
    public Wrapper<Page<KbaseFileVersionApply>> page(@CurrentUser KbaseAuthUser user, @RequestBody KbaseFileVersionApplyVo vo) {
        return Wrapper.ok(applyService.page(user, vo));
    }
}

